package recursion;

/**
 * @author kaho
 * @since 2020/12/21
 */
public class 汉诺塔 {


    public static void hanoi(int n, String p1, String p2, String p3){
        if (n<=1) {
            move(n, p1, p3);
            return;
        }
        hanoi(n -1, p1, p3, p2);
        move(n, p1, p3);
        hanoi(n-1, p2, p1, p3);
    }

    private static void move(int n, String from, String to) {
        System.out.println(n + "号盘子 从 " + from + "移动到" + to);
    }

}
